From 58791370722cbbde8a9299910da6af4c356ee30d Mon Sep 17 00:00:00 2001 From: robertl Date: Thu, 23 Oct 2003 06:10:57 +0000 Subject: [PATCH] Large and boring search and replace to remove structs that had only one member. wpt->position.altitude.altitude_meters becomes wpt->altitude, for example. --- gpsbabel/Makefile | 3 +- gpsbabel/arcdist.c | 4 +- gpsbabel/cetus.c | 16 +++---- gpsbabel/copilot.c | 12 +++--- gpsbabel/csv_util.c | 48 ++++++++++----------- gpsbabel/defs.h | 37 +++------------- gpsbabel/duplicate.c | 4 +- gpsbabel/easygps.c | 8 ++-- gpsbabel/garmin.c | 22 +++++----- gpsbabel/gcdb.c | 20 ++++----- gpsbabel/geo.c | 10 ++--- gpsbabel/gpilots.c | 12 +++--- gpsbabel/gpsdrive.c | 8 ++-- gpsbabel/gpspilot.c | 12 +++--- gpsbabel/gpsutil.c | 12 +++--- gpsbabel/gpx.c | 34 +++++++-------- gpsbabel/holux.c | 10 ++--- gpsbabel/magnav.c | 12 +++--- gpsbabel/mapopolis.c | 10 ++--- gpsbabel/mapsend.c | 36 ++++++++-------- gpsbabel/mapsource.c | 100 +++++++++++++++++++++---------------------- gpsbabel/navicache.c | 6 +-- gpsbabel/pcx.c | 10 ++--- gpsbabel/polygon.c | 4 +- gpsbabel/position.c | 28 ++++++------ gpsbabel/psitrex.c | 42 +++++++++--------- gpsbabel/psp.c | 14 +++--- gpsbabel/quovadis.c | 8 ++-- gpsbabel/saroute.c | 8 ++-- gpsbabel/tiger.c | 8 ++-- gpsbabel/tmpro.c | 12 +++--- gpsbabel/tpg.c | 12 +++--- gpsbabel/util.c | 22 +++++----- gpsbabel/waypt.c | 8 ++-- 34 files changed, 295 insertions(+), 317 deletions(-) diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index 35abf74e1..6907f8b10 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -116,13 +116,14 @@ navicache.o: navicache.c defs.h queue.h pcx.o: pcx.c defs.h queue.h garmin_tables.h polygon.o: polygon.c defs.h queue.h position.o: position.c defs.h queue.h +psitrex.o: psitrex.c defs.h queue.h garmin_tables.h psp.o: psp.c defs.h queue.h queue.o: queue.c queue.h quovadis.o: quovadis.c quovadis.h defs.h queue.h coldsync/palm.h \ coldsync/pdb.h route.o: route.c defs.h queue.h saroute.o: saroute.c defs.h queue.h -tiger.o: tiger.c defs.h queue.h magellan.h csv_util.h +tiger.o: tiger.c defs.h queue.h csv_util.h tmpro.o: tmpro.c defs.h queue.h csv_util.h tpg.o: tpg.c defs.h queue.h jeeps/gpsmath.h jeeps/gps.h jeeps/gpsport.h \ jeeps/gpsserial.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ diff --git a/gpsbabel/arcdist.c b/gpsbabel/arcdist.c index 544072299..e4bf0e7f4 100644 --- a/gpsbabel/arcdist.c +++ b/gpsbabel/arcdist.c @@ -256,8 +256,8 @@ arcdist_process(void) waypointp = (waypoint *)elem; dist = linedist(lat1, lon1, lat2, lon2, - waypointp->position.latitude.degrees, - waypointp->position.longitude.degrees ); + waypointp->latitude, + waypointp->longitude ); /* convert radians to float point statute miles */ dist = (((dist * 180.0 * 60.0) / M_PI) * 1.1516); diff --git a/gpsbabel/cetus.c b/gpsbabel/cetus.c index 9d9ebb374..94f6ef74e 100644 --- a/gpsbabel/cetus.c +++ b/gpsbabel/cetus.c @@ -159,14 +159,14 @@ data_read(void) rec = (struct record *) pdb_rec->data; if ( be_read32(&rec->elevation) == -100000000 ) { - wpt_tmp->position.altitude.altitude_meters = unknown_alt; + wpt_tmp->altitude = unknown_alt; } else { - wpt_tmp->position.altitude.altitude_meters = be_read32(&rec->elevation) / 100.0; + wpt_tmp->altitude = be_read32(&rec->elevation) / 100.0; } - wpt_tmp->position.longitude.degrees = be_read32(&rec->longitude) / 10000000.0; - wpt_tmp->position.latitude.degrees = be_read32(&rec->latitude) / 10000000.0; + wpt_tmp->longitude = be_read32(&rec->longitude) / 10000000.0; + wpt_tmp->latitude = be_read32(&rec->latitude) / 10000000.0; if (be_read16(&rec->year) != 0xff) { struct tm tm; @@ -225,13 +225,13 @@ cetus_writewpt(waypoint *wpt) be_write16(&rec->year, 0xff); } - be_write32(&rec->longitude, wpt->position.longitude.degrees * 10000000.0); - be_write32(&rec->latitude, wpt->position.latitude.degrees * 10000000.0); - if ( wpt->position.altitude.altitude_meters == unknown_alt ) { + be_write32(&rec->longitude, wpt->longitude * 10000000.0); + be_write32(&rec->latitude, wpt->latitude * 10000000.0); + if ( wpt->altitude == unknown_alt ) { be_write32(&rec->elevation, -100000000U); } else { - be_write32(&rec->elevation, wpt->position.altitude.altitude_meters * 100.0); + be_write32(&rec->elevation, wpt->altitude * 100.0); } be_write16( &rec->pdop, 0xffff ); diff --git a/gpsbabel/copilot.c b/gpsbabel/copilot.c index 7a15bdb0e..5bba68a98 100644 --- a/gpsbabel/copilot.c +++ b/gpsbabel/copilot.c @@ -101,11 +101,11 @@ data_read(void) wpt_tmp = xcalloc(sizeof(*wpt_tmp),1); rec = (struct record *) pdb_rec->data; - wpt_tmp->position.longitude.degrees = + wpt_tmp->longitude = -pdb_read_double(&rec->longitude) * conv; - wpt_tmp->position.latitude.degrees = + wpt_tmp->latitude = pdb_read_double(&rec->latitude) * conv; - wpt_tmp->position.altitude.altitude_meters = + wpt_tmp->altitude = pdb_read_double(&rec->elevation) * .3048; vdata = (char *) pdb_rec->data + sizeof(*rec); @@ -134,11 +134,11 @@ copilot_writewpt(const waypoint *wpt) rec = xcalloc(sizeof(*rec)+1141,1); - pdb_write_double(&rec->latitude, wpt->position.latitude.degrees / conv); + pdb_write_double(&rec->latitude, wpt->latitude / conv); pdb_write_double(&rec->longitude, - -wpt->position.longitude.degrees / conv); + -wpt->longitude / conv); pdb_write_double(&rec->elevation, - wpt->position.altitude.altitude_meters / .3048); + wpt->altitude / .3048); pdb_write_double(&rec->magvar, 0); vdata = (char *)rec + sizeof(*rec); diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index b87470b77..45e11d2e1 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -427,30 +427,30 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp) /* LATITUDE CONVERSIONS**************************************************/ if (strcmp(fmp->key, "LAT_DECIMAL") == 0) { /* latitude as a pure decimal value */ - wpt->position.latitude.degrees = atof(s); + wpt->latitude = atof(s); } else if ((strcmp(fmp->key, "LAT_DECIMALDIR") == 0) || (strcmp(fmp->key, "LAT_DIRDECIMAL") == 0)) { /* latitude as a decimal with N/S in it. */ - wpt->position.latitude.degrees = decdir_to_dec(s); + wpt->latitude = decdir_to_dec(s); } else if (strcmp(fmp->key, "LAT_INT32DEG") == 0) { /* latitude as a 32 bit integer offset */ - wpt->position.latitude.degrees = intdeg_to_dec(atof(s), 1); + wpt->latitude = intdeg_to_dec(atof(s), 1); } else /* LONGITUDE CONVERSIONS ***********************************************/ if (strcmp(fmp->key, "LON_DECIMAL") == 0) { /* longitude as a pure decimal value */ - wpt->position.longitude.degrees = atof(s); + wpt->longitude = atof(s); } else if ((strcmp(fmp->key, "LON_DECIMALDIR") == 0) || (strcmp(fmp->key, "LON_DIRDECIMAL") == 0)) { /* longitude as a decimal with N/S in it. */ - wpt->position.longitude.degrees = decdir_to_dec(s); + wpt->longitude = decdir_to_dec(s); } else if (strcmp(fmp->key, "LON_INT32DEG") == 0) { /* longitude as a 32 bit integer offset */ - wpt->position.longitude.degrees = intdeg_to_dec(atof(s), 0); + wpt->longitude = intdeg_to_dec(atof(s), 0); } else /* DIRECTIONS **********************************************************/ @@ -464,11 +464,11 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp) /* ALTITUDE CONVERSIONS ************************************************/ if (strcmp(fmp->key, "ALT_FEET") == 0) { /* altitude in feet as a decimal value */ - wpt->position.altitude.altitude_meters = atof(s) * .3048; + wpt->altitude = atof(s) * .3048; } else if (strcmp(fmp->key, "ALT_METERS") == 0) { /* altitude in meters as a decimal value */ - wpt->position.altitude.altitude_meters = atof(s); + wpt->altitude = atof(s); } else /* TIME CONVERSIONS ***************************************************/ @@ -691,70 +691,70 @@ xcsv_waypt_pr(const waypoint *wpt) /* LATITUDE CONVERSION***********************************************/ if (strcmp(fmp->key, "LAT_DECIMAL") == 0) { /* latitude as a pure decimal value */ - sprintf(buff, fmp->printfc, wpt->position.latitude.degrees); + sprintf(buff, fmp->printfc, wpt->latitude); } else if (strcmp(fmp->key, "LAT_DECIMALDIR") == 0) { /* latitude as a decimal value with N/S after it */ - sprintf(buff, fmp->printfc, fabs(wpt->position.latitude.degrees), - LAT_DIR(wpt->position.latitude.degrees)); + sprintf(buff, fmp->printfc, fabs(wpt->latitude), + LAT_DIR(wpt->latitude)); } else if (strcmp(fmp->key, "LAT_DIRDECIMAL") == 0) { /* latitude as a decimal value with N/S before it */ sprintf(buff, fmp->printfc, - LAT_DIR(wpt->position.latitude.degrees), - fabs(wpt->position.latitude.degrees)); + LAT_DIR(wpt->latitude), + fabs(wpt->latitude)); } else if (strcmp(fmp->key, "LAT_INT32DEG") == 0) { /* latitude as an integer offset from 0 degrees */ sprintf(buff, fmp->printfc, - dec_to_intdeg(wpt->position.latitude.degrees, 1)); + dec_to_intdeg(wpt->latitude, 1)); } else /* LONGITUDE CONVERSIONS*********************************************/ if (strcmp(fmp->key, "LON_DECIMAL") == 0) { /* longitude as a pure decimal value */ - sprintf(buff, fmp->printfc, wpt->position.longitude.degrees); + sprintf(buff, fmp->printfc, wpt->longitude); } else if (strcmp(fmp->key, "LON_DECIMALDIR") == 0) { /* latitude as a decimal value with N/S after it */ sprintf(buff, fmp->printfc, - fabs(wpt->position.longitude.degrees), - LON_DIR(wpt->position.longitude.degrees)); + fabs(wpt->longitude), + LON_DIR(wpt->longitude)); } else if (strcmp(fmp->key, "LON_DIRDECIMAL") == 0) { /* latitude as a decimal value with N/S before it */ sprintf(buff, fmp->printfc, - LON_DIR(wpt->position.longitude.degrees), - fabs(wpt->position.longitude.degrees)); + LON_DIR(wpt->longitude), + fabs(wpt->longitude)); } else if (strcmp(fmp->key, "LON_INT32DEG") == 0) { /* longitudee as an integer offset from 0 degrees */ sprintf(buff, fmp->printfc, - dec_to_intdeg(wpt->position.longitude.degrees, 0)); + dec_to_intdeg(wpt->longitude, 0)); } else /* DIRECTIONS *******************************************************/ if (strcmp(fmp->key, "LAT_DIR") == 0) { /* latitude N/S as a char */ sprintf(buff, fmp->printfc, - LAT_DIR(wpt->position.latitude.degrees)); + LAT_DIR(wpt->latitude)); } else if (strcmp(fmp->key, "LON_DIR") == 0) { /* longitude E/W as a char */ sprintf(buff, fmp->printfc, - LON_DIR(wpt->position.longitude.degrees)); + LON_DIR(wpt->longitude)); } else /* ALTITUDE CONVERSIONS**********************************************/ if (strcmp(fmp->key, "ALT_FEET") == 0) { /* altitude in feet as a decimal value */ sprintf(buff, fmp->printfc, - (wpt->position.altitude.altitude_meters * 3.2808)); + (wpt->altitude * 3.2808)); } else if (strcmp(fmp->key, "ALT_METERS") == 0) { /* altitude in meters as a decimal value */ sprintf(buff, fmp->printfc, - wpt->position.altitude.altitude_meters); + wpt->altitude); } else /* TIME CONVERSIONS**************************************************/ diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index bed231345..27a18276b 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -31,34 +31,6 @@ */ -/* - * A coordinate in space. - */ -typedef struct { - double degrees; -} coord; - - -/* - * An altitude is essentially a coordinate along only the Z axis. - */ - -typedef struct { - double altitude_meters; -} altitude; - - -/* - * A triplet of the coordinates along the three axes describes - * a position. - */ -typedef struct { - coord latitude; - coord longitude; - altitude altitude; -} position; - - /* * Define globally on which kind of data gpsbabel is working. * Important for "file types" that are essentially a communication @@ -132,7 +104,10 @@ typedef struct xml_tag { */ typedef struct { queue Q; - position position; + + double latitude; /* Degrees */ + double longitude; /* Degrees */ + double altitude; /* Meters. */ /* * The "thickness" of a waypoint; adds an element of 3D. Can be @@ -205,7 +180,7 @@ typedef void (*filter_init) (char const *); typedef void (*filter_process) (void); typedef void (*filter_deinit) (void); -void fprintdms(FILE *, const coord *, int); +// void fprintdms(FILE *, const coord *, int); typedef void (*waypt_cb) (const waypoint *); typedef void (*route_hdr)(const route_head *); @@ -311,7 +286,7 @@ void warning(const char *, ...) ff_vecs_t *find_vec(char *, char **); void disp_vecs(void); void disp_formats(int version); -void printposn(const coord *c, int is_lat); +void printposn(float c, int is_lat); filter_vecs_t * find_filter_vec(char *, char **); void free_filter_vec(filter_vecs_t *); diff --git a/gpsbabel/duplicate.c b/gpsbabel/duplicate.c index d575460dd..a7846e40b 100644 --- a/gpsbabel/duplicate.c +++ b/gpsbabel/duplicate.c @@ -255,8 +255,8 @@ duplicate_process(void) if (lcopt) { /* let sprintf take care of rounding */ - sprintf(dupe.lat, "%11.6f", waypointp->position.latitude.degrees); - sprintf(dupe.lon, "%11.6f", waypointp->position.longitude.degrees); + sprintf(dupe.lat, "%11.6f", waypointp->latitude); + sprintf(dupe.lon, "%11.6f", waypointp->longitude); } crc = get_crc32(&dupe, sizeof(dupe)); diff --git a/gpsbabel/easygps.c b/gpsbabel/easygps.c index d7952e40d..85def6324 100644 --- a/gpsbabel/easygps.c +++ b/gpsbabel/easygps.c @@ -163,12 +163,12 @@ data_read(void) case 0x63: fread(ibuf, 8, 1, file_in); le_read64(&d, ibuf); - wpt_tmp->position.latitude.degrees = d; + wpt_tmp->latitude = d; break; case 0x64: fread(ibuf, 8, 1, file_in); le_read64(&d, ibuf); - wpt_tmp->position.longitude.degrees = d; + wpt_tmp->longitude = d; break; case 0x65: case 0x66: @@ -225,10 +225,10 @@ ez_disp(const waypoint *wpt) write_pstring(wpt->icon_descr); } fputc(0x63, file_out); - le_read64(tbuf, &wpt->position.latitude.degrees); + le_read64(tbuf, &wpt->latitude); fwrite(tbuf, 8, 1, file_out); fputc(0x64, file_out); - le_read64(tbuf, &wpt->position.longitude.degrees); + le_read64(tbuf, &wpt->longitude); fwrite(tbuf, 8, 1, file_out); if (wpt->notes) { fputc(5, file_out); diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 0e4d21596..1b7efb6a9 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -75,8 +75,8 @@ waypt_read(void) wpt_tmp->shortname = xstrdup(way[i]->ident); wpt_tmp->description = xstrdup(way[i]->cmnt); - wpt_tmp->position.longitude.degrees = way[i]->lon; - wpt_tmp->position.latitude.degrees = way[i]->lat; + wpt_tmp->longitude = way[i]->lon; + wpt_tmp->latitude = way[i]->lat; wpt_tmp->icon_descr = mps_find_desc_from_icon_number(way[i]->smbl, PCX); /* @@ -92,9 +92,9 @@ waypt_read(void) (way[i]->alt == INT_MAX) || (way[i]->alt == 1.0e25) ) { - wpt_tmp->position.altitude.altitude_meters = unknown_alt; + wpt_tmp->altitude = unknown_alt; } else { - wpt_tmp->position.altitude.altitude_meters = way[i]->alt; + wpt_tmp->altitude = way[i]->alt; } waypt_add(wpt_tmp); @@ -128,9 +128,9 @@ track_read(void) route_add_head(trk_head); } - waypts[i].position.longitude.degrees = array[i]->lon; - waypts[i].position.latitude.degrees = array[i]->lat; - waypts[i].position.altitude.altitude_meters = array[i]->alt; + waypts[i].longitude = array[i]->lon; + waypts[i].latitude = array[i]->lat; + waypts[i].altitude = array[i]->alt; waypts[i].shortname = xstrdup(array[i]->trk_ident); waypts[i].creation_time = array[i]->Time; @@ -262,11 +262,11 @@ data_write(void) if (src && strlen(src)) { strncpy(way[i]->cmnt, src, sizeof(way[i]->cmnt)); } - way[i]->lon = wpt->position.longitude.degrees; - way[i]->lat = wpt->position.latitude.degrees; + way[i]->lon = wpt->longitude; + way[i]->lat = wpt->latitude; way[i]->smbl = mps_find_icon_number_from_desc(wpt->icon_descr, PCX); - if (wpt->position.altitude.altitude_meters != unknown_alt) { - way[i]->alt = wpt->position.altitude.altitude_meters; + if (wpt->altitude != unknown_alt) { + way[i]->alt = wpt->altitude; } i++; } diff --git a/gpsbabel/gcdb.c b/gpsbabel/gcdb.c index 39d44b0e9..861a3c086 100644 --- a/gpsbabel/gcdb.c +++ b/gpsbabel/gcdb.c @@ -183,8 +183,8 @@ data_read(void) } recdata += (length + 1) & (~1); } - wpt->position.latitude.degrees = lat_dir * (lat_deg + lat_min/60); - wpt->position.longitude.degrees = lon_dir * (lon_deg + lon_min/60); + wpt->latitude = lat_dir * (lat_deg + lat_min/60); + wpt->longitude = lon_dir * (lon_deg + lon_min/60); waypt_add(wpt); } @@ -255,24 +255,24 @@ gcdb_write_wpt(const waypoint *wpt) gcdb_add_to_rec(rec, "gcid", RECTYPE_TEXT, wpt->shortname); gcdb_add_to_rec(rec, "lat0", RECTYPE_TEXT, - wpt->position.latitude.degrees < 0 ? "S" : "N"); + wpt->latitude < 0 ? "S" : "N"); - sprintf(tbuf, "%d", (int) wpt->position.latitude.degrees); + sprintf(tbuf, "%d", (int) wpt->latitude); gcdb_add_to_rec(rec, "lat1", RECTYPE_TEXT, tbuf); - sprintf(tbuf, "%f", 60 * (wpt->position.latitude.degrees - - (int) wpt->position.latitude.degrees)); + sprintf(tbuf, "%f", 60 * (wpt->latitude - + (int) wpt->latitude)); gcdb_add_to_rec(rec, "lat2", RECTYPE_TEXT, tbuf); gcdb_add_to_rec(rec, "lon0", RECTYPE_TEXT, - wpt->position.longitude.degrees < 0 ? "W" : "E"); + wpt->longitude < 0 ? "W" : "E"); - sprintf(tbuf, "%d", (int) wpt->position.longitude.degrees); + sprintf(tbuf, "%d", (int) wpt->longitude); gcdb_add_to_rec(rec, "lon1", RECTYPE_TEXT, tbuf); - sprintf(tbuf, "%f", 60 * (wpt->position.longitude.degrees - - (int) wpt->position.longitude.degrees)); + sprintf(tbuf, "%f", 60 * (wpt->longitude - + (int) wpt->longitude)); gcdb_add_to_rec(rec, "lon2", RECTYPE_TEXT, tbuf); if (wpt->gc_data.diff) { diff --git a/gpsbabel/geo.c b/gpsbabel/geo.c index f5d6da537..aa5f013c0 100644 --- a/gpsbabel/geo.c +++ b/gpsbabel/geo.c @@ -59,11 +59,11 @@ tag_coord(const char **attrv) while (*avp) { if (strcmp(avp[0], "lat") == 0) { sscanf(avp[1], "%lf", - &wpt_tmp->position.latitude.degrees); + &wpt_tmp->latitude); } else if (strcmp(avp[0], "lon") == 0) { sscanf(avp[1], "%lf", - &wpt_tmp->position.longitude.degrees); + &wpt_tmp->longitude); } avp+=2; } @@ -111,7 +111,7 @@ geo_start(void *data, const char *el, const char **attr) if (in_wpt) { if (strcmp(el, "ele") == 0) { - wpt_tmp->position.altitude.altitude_meters = atoi(attr[1]); + wpt_tmp->altitude = atoi(attr[1]); } else if (strcmp(el, "name") == 0) { tag_name(attr); @@ -258,8 +258,8 @@ geo_waypt_pr(const waypoint *waypointp) fprintf(ofd, "\n"); fprintf(ofd, "", - waypointp->position.latitude.degrees, - waypointp->position.longitude.degrees); + waypointp->latitude, + waypointp->longitude); fprintf(ofd, "\n"); if (waypointp->icon_descr) { diff --git a/gpsbabel/gpilots.c b/gpsbabel/gpilots.c index 92f437df3..21660b015 100644 --- a/gpsbabel/gpilots.c +++ b/gpsbabel/gpilots.c @@ -210,8 +210,8 @@ data_read(void) */ lon = le_read32(&rec->wpt.d103.lon); lat = le_read32(&rec->wpt.d103.lat); - wpt_tmp->position.longitude.degrees = lon / 2147483648.0 * 180.0; - wpt_tmp->position.latitude.degrees = lat / 2147483648.0 * 180.0; + wpt_tmp->longitude = lon / 2147483648.0 * 180.0; + wpt_tmp->latitude = lat / 2147483648.0 * 180.0; waypt_add(wpt_tmp); break; /* @@ -228,8 +228,8 @@ data_read(void) wpt_tmp = xcalloc(sizeof(*wpt_tmp),1); lon = le_read32(&tp->lon); lat = le_read32(&tp->lat); - wpt_tmp->position.longitude.degrees = lon / 2147483648.0 * 180.0; - wpt_tmp->position.latitude.degrees = lat / 2147483648.0 * 180.0; + wpt_tmp->longitude = lon / 2147483648.0 * 180.0; + wpt_tmp->latitude = lat / 2147483648.0 * 180.0; route_add_wpt(track_head, wpt_tmp); tp++; } @@ -262,8 +262,8 @@ my_write_wpt(const waypoint *wpt) rec->header.type = 4; strncpy(rec->wpt.d103.ident, wpt->shortname, sizeof(rec->wpt.d103.ident)); strncpy(rec->wpt.d103.cmnt, wpt->description, sizeof(rec->wpt.d103.cmnt)); - lat = wpt->position.latitude.degrees / 180.0 * 2147483648.0; - lon = wpt->position.longitude.degrees / 180.0 * 2147483648.0; + lat = wpt->latitude / 180.0 * 2147483648.0; + lon = wpt->longitude / 180.0 * 2147483648.0; le_write32(&rec->wpt.d103.lat, lat); le_write32(&rec->wpt.d103.lon, lon); diff --git a/gpsbabel/gpsdrive.c b/gpsbabel/gpsdrive.c index 1fb701ab1..2a785e1db 100644 --- a/gpsbabel/gpsdrive.c +++ b/gpsbabel/gpsdrive.c @@ -101,10 +101,10 @@ data_read(void) wpt_tmp->description = csv_stringtrim(s, " "); break; case 1: - wpt_tmp->position.latitude.degrees = atof(s); + wpt_tmp->latitude = atof(s); break; case 2: - wpt_tmp->position.longitude.degrees = atof(s); + wpt_tmp->longitude = atof(s); break; case 3: rtrim(s); @@ -146,8 +146,8 @@ gpsdrive_waypt_pr(const waypoint *wpt) char *isrc, *owpt; char *tmpstr; - lon = wpt->position.longitude.degrees; - lat = wpt->position.latitude.degrees; + lon = wpt->longitude; + lat = wpt->latitude; isrc = wpt->notes ? wpt->notes : wpt->description; if (global_opts.synthesize_shortnames) { diff --git a/gpsbabel/gpspilot.c b/gpsbabel/gpspilot.c index 36805443d..1b5e8538a 100644 --- a/gpsbabel/gpspilot.c +++ b/gpsbabel/gpspilot.c @@ -131,9 +131,9 @@ data_read(void) wpt_tmp = xcalloc(sizeof(*wpt_tmp),1); rec = (struct record *) pdb_rec->data; - wpt_tmp->position.longitude.degrees = be_read32(&rec->longitude) / 3.6e6; - wpt_tmp->position.latitude.degrees = be_read32(&rec->latitude) / 3.6e6; - wpt_tmp->position.altitude.altitude_meters = + wpt_tmp->longitude = be_read32(&rec->longitude) / 3.6e6; + wpt_tmp->latitude = be_read32(&rec->latitude) / 3.6e6; + wpt_tmp->altitude = be_read16(&rec->elevation); vdata = (char *) pdb_rec->data + sizeof(*rec); @@ -181,9 +181,9 @@ gpspilot_writewpt(const waypoint *wpt) rec = xcalloc(sizeof(*rec)+206,1); - be_write32(&rec->longitude, si_round(wpt->position.longitude.degrees * 3.6e6)); - be_write32(&rec->latitude, si_round(wpt->position.latitude.degrees * 3.6e6)); - be_write16(&rec->elevation, si_round(wpt->position.altitude.altitude_meters)); + be_write32(&rec->longitude, si_round(wpt->longitude * 3.6e6)); + be_write32(&rec->latitude, si_round(wpt->latitude * 3.6e6)); + be_write16(&rec->elevation, si_round(wpt->altitude)); be_write16(&rec->magvar, 0 ); vdata = (char *)rec + sizeof(*rec); diff --git a/gpsbabel/gpsutil.c b/gpsbabel/gpsutil.c index a0410ba66..1b536ef50 100644 --- a/gpsbabel/gpsutil.c +++ b/gpsbabel/gpsutil.c @@ -68,7 +68,7 @@ data_read(void) rtrim(desc); rtrim(icon); wpt_tmp = xcalloc(sizeof(*wpt_tmp),1); - wpt_tmp->position.altitude.altitude_meters = alt; + wpt_tmp->altitude = alt; wpt_tmp->shortname = xstrdup(name); wpt_tmp->description = xstrdup(desc); wpt_tmp->creation_time = time(NULL); @@ -79,9 +79,9 @@ data_read(void) lat /= 100.0; lon /= 100.0; ilon = (int)(lon); - wpt_tmp->position.longitude.degrees = ilon + (lon - ilon)*(100.0/60.0); + wpt_tmp->longitude = ilon + (lon - ilon)*(100.0/60.0); ilat = (int)(lat); - wpt_tmp->position.latitude.degrees = ilat + (lat - ilat) * (100.0/60.0); + wpt_tmp->latitude = ilat + (lat - ilat) * (100.0/60.0); wpt_tmp->icon_descr = mag_find_descr_from_token(icon); waypt_add(wpt_tmp); } @@ -95,8 +95,8 @@ gpsutil_disp(const waypoint *wpt) icon_token = mag_find_token_from_descr(wpt->icon_descr); - lon = degrees2ddmm(wpt->position.longitude.degrees); - lat = degrees2ddmm(wpt->position.latitude.degrees); + lon = degrees2ddmm(wpt->longitude); + lat = degrees2ddmm(wpt->latitude); fprintf(file_out, "%-8s %08.3f%c %09.3f%c %07.0f%c %-30.30s %s\n", global_opts.synthesize_shortnames ? @@ -106,7 +106,7 @@ gpsutil_disp(const waypoint *wpt) lat < 0.0 ? 'S' : 'N', fabs(lon), lon < 0.0 ? 'W' : 'E', - wpt->position.altitude.altitude_meters, + wpt->altitude, 'm', wpt->description ? wpt->description : "", icon_token); diff --git a/gpsbabel/gpx.c b/gpsbabel/gpx.c index 01c021587..244e60db3 100644 --- a/gpsbabel/gpx.c +++ b/gpsbabel/gpx.c @@ -163,11 +163,11 @@ tag_wpt(const char **attrv) while (*avp) { if (strcmp(avp[0], "lat") == 0) { sscanf(avp[1], "%lf", - &wpt_tmp->position.latitude.degrees); + &wpt_tmp->latitude); } else if (strcmp(avp[0], "lon") == 0) { sscanf(avp[1], "%lf", - &wpt_tmp->position.longitude.degrees); + &wpt_tmp->longitude); } avp+=2; } @@ -257,11 +257,11 @@ tag_log_wpt(const char **attrv) while (*avp) { if (strcmp(avp[0], "lat") == 0) { sscanf(avp[1], "%lf", - &lwp_tmp->position.latitude.degrees); + &lwp_tmp->latitude); } else if (strcmp(avp[0], "lon") == 0) { sscanf(avp[1], "%lf", - &lwp_tmp->position.longitude.degrees); + &lwp_tmp->longitude); } avp+=2; } @@ -564,7 +564,7 @@ gpx_end(void *data, const char *el) } if (in_ele) { sscanf(cdatastr, "%lf", - &wpt_tmp->position.altitude.altitude_meters); + &wpt_tmp->altitude); } if (in_time) { if ( in_wpt || in_rte || in_trkpt || in_rtept) { @@ -965,8 +965,8 @@ gpx_waypt_pr(const waypoint *waypointp) waypointp->shortname; fprintf(ofd, "\n", - waypointp->position.latitude.degrees, - waypointp->position.longitude.degrees); + waypointp->latitude, + waypointp->longitude); if (waypointp->creation_time) { gpx_write_time(waypointp->creation_time, "time"); } @@ -991,9 +991,9 @@ gpx_waypt_pr(const waypoint *waypointp) fprintf(ofd, "\n"); } } - if (waypointp->position.altitude.altitude_meters) { + if (waypointp->altitude) { fprintf(ofd, "\n%f\n\n", - waypointp->position.altitude.altitude_meters); + waypointp->altitude); } if (waypointp->url) { tmp_ent = gpx_entitize(waypointp->url); @@ -1041,11 +1041,11 @@ static void gpx_track_disp(const waypoint *waypointp) { fprintf(ofd, "\n", - waypointp->position.latitude.degrees, - waypointp->position.longitude.degrees); - if (waypointp->position.altitude.altitude_meters != unknown_alt) { + waypointp->latitude, + waypointp->longitude); + if (waypointp->altitude != unknown_alt) { fprintf(ofd, "%f\n", - waypointp->position.altitude.altitude_meters); + waypointp->altitude); } if (waypointp->creation_time) { gpx_write_time(waypointp->creation_time,"time"); @@ -1091,12 +1091,12 @@ static void gpx_route_disp(const waypoint *waypointp) { fprintf(ofd, "\n", - waypointp->position.latitude.degrees, - waypointp->position.longitude.degrees); + waypointp->latitude, + waypointp->longitude); - if (waypointp->position.altitude.altitude_meters != unknown_alt) { + if (waypointp->altitude != unknown_alt) { fprintf(ofd, "%f\n", - waypointp->position.altitude.altitude_meters); + waypointp->altitude); } if (waypointp->creation_time) { gpx_write_time(waypointp->creation_time,"time"); diff --git a/gpsbabel/holux.c b/gpsbabel/holux.c index 14e1a9373..8a9931c87 100644 --- a/gpsbabel/holux.c +++ b/gpsbabel/holux.c @@ -113,7 +113,7 @@ static void data_read(void) iWptIndex = le_read16(&((WPTHDR *)HxWpt)->idx[iCount]); pWptHxTmp = (WPT *)&HxWpt[OFFS_WPT + (sizeof(WPT) * iWptIndex)]; - wpt_tmp->position.altitude.altitude_meters = 0; + wpt_tmp->altitude = 0; strncpy(name,pWptHxTmp->name,sizeof(pWptHxTmp->name)); name[sizeof(pWptHxTmp->name)]=0; @@ -139,8 +139,8 @@ static void data_read(void) lon = le_read32(&pWptHxTmp->pt.iLongitude) / 36000.0; lat = (le_read32(&pWptHxTmp->pt.iLatitude) / 36000.0) * -1.0; - wpt_tmp->position.longitude.degrees = lon; - wpt_tmp->position.latitude.degrees = lat; + wpt_tmp->longitude = lon; + wpt_tmp->latitude = lat; waypt_add(wpt_tmp); } xfree(HxWpt); @@ -184,8 +184,8 @@ static void holux_disp(const waypoint *wpt) short sIndex; WPT *pWptHxTmp; - lon =(double)wpt->position.longitude.degrees * 36000; - lat =(double)wpt->position.latitude.degrees * -36000; + lon =(double)wpt->longitude * 36000; + lat =(double)wpt->latitude * -36000; /* round it to increase the accuracy */ diff --git a/gpsbabel/magnav.c b/gpsbabel/magnav.c index f7c13815e..03068d2d9 100644 --- a/gpsbabel/magnav.c +++ b/gpsbabel/magnav.c @@ -114,10 +114,10 @@ data_read(void) memset (&tm, sizeof(tm), 0); wpt_tmp = xcalloc(sizeof(*wpt_tmp),1); rec = (struct record *) pdb_rec->data; - wpt_tmp->position.altitude.altitude_meters = be_read32(&rec->elevation); + wpt_tmp->altitude = be_read32(&rec->elevation); - wpt_tmp->position.longitude.degrees = be_read32(&rec->longitude) / 1e5; - wpt_tmp->position.latitude.degrees = be_read32(&rec->latitude) / 1e5; + wpt_tmp->longitude = be_read32(&rec->longitude) / 1e5; + wpt_tmp->latitude = be_read32(&rec->latitude) / 1e5; vdata = (char *) pdb_rec->data + sizeof(*rec); @@ -183,9 +183,9 @@ my_writewpt(const waypoint *wpt) be_write16( &rec->unknown2, 0); - be_write32(&rec->longitude, si_round(wpt->position.longitude.degrees * 100000.0)); - be_write32(&rec->latitude, si_round(wpt->position.latitude.degrees * 100000.0)); - be_write32(&rec->elevation, wpt->position.altitude.altitude_meters); + be_write32(&rec->longitude, si_round(wpt->longitude * 100000.0)); + be_write32(&rec->latitude, si_round(wpt->latitude * 100000.0)); + be_write32(&rec->elevation, wpt->altitude); rec->plot = 0; rec->unknown3 = 'a'; diff --git a/gpsbabel/mapopolis.c b/gpsbabel/mapopolis.c index 2cf8f9a99..c88512683 100644 --- a/gpsbabel/mapopolis.c +++ b/gpsbabel/mapopolis.c @@ -164,9 +164,9 @@ decode(char *buf) for (; vdata < edata; rec = (struct record *) vdata) { wpt_tmp = xcalloc(sizeof(*wpt_tmp),1); - wpt_tmp->position.latitude.degrees = Lat1 + + wpt_tmp->latitude = Lat1 + be_read16(&rec->lat1d) / LATDIV2; - wpt_tmp->position.longitude.degrees = Lon1 + + wpt_tmp->longitude = Lon1 + be_read16(&rec->lon1d) / LONDIV2; vdata = (char *) rec + sizeof(*rec); @@ -228,9 +228,9 @@ my_writewpt(const waypoint *wpt) be_write16( &rec->unknown2, 0); - be_write32(&rec->longitude, si_round(wpt->position.longitude.degrees * 100000.0)); - be_write32(&rec->latitude, si_round(wpt->position.latitude.degrees * 100000.0)); - be_write32(&rec->elevation, wpt->position.altitude.altitude_meters); + be_write32(&rec->longitude, si_round(wpt->longitude * 100000.0)); + be_write32(&rec->latitude, si_round(wpt->latitude * 100000.0)); + be_write32(&rec->elevation, wpt->altitude); rec->plot = 0; rec->unknown3 = 'a'; diff --git a/gpsbabel/mapsend.c b/gpsbabel/mapsend.c index 43da0edca..23af6e9e0 100644 --- a/gpsbabel/mapsend.c +++ b/gpsbabel/mapsend.c @@ -231,9 +231,9 @@ mapsend_wpt_read(void) wpt_tmp->shortname = xstrdup(name); wpt_tmp->description = xstrdup(comment); - wpt_tmp->position.altitude.altitude_meters = wpt_alt; - wpt_tmp->position.latitude.degrees = -wpt_lat; - wpt_tmp->position.longitude.degrees = wpt_long; + wpt_tmp->altitude = wpt_alt; + wpt_tmp->latitude = -wpt_lat; + wpt_tmp->longitude = wpt_long; if (wpt_icon < 26) sprintf(tbuf, "%c", wpt_icon + 'a'); @@ -280,8 +280,8 @@ mapsend_wpt_read(void) my_fread8(&wpt_lat, mapsend_file_in); fread(&wpt_icon, sizeof(wpt_icon), 1, mapsend_file_in); - wpt_tmp->position.longitude.degrees = wpt_long; - wpt_tmp->position.latitude.degrees = -wpt_lat; + wpt_tmp->longitude = wpt_long; + wpt_tmp->latitude = -wpt_lat; if (wpt_icon < 26) sprintf(tbuf, "%c", wpt_icon + 'a'); @@ -342,11 +342,11 @@ mapsend_track_read(void) } wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1); - wpt_tmp->position.latitude.degrees = -wpt_lat; - wpt_tmp->position.longitude.degrees = wpt_long; + wpt_tmp->latitude = -wpt_lat; + wpt_tmp->longitude = wpt_long; wpt_tmp->creation_time = time; wpt_tmp->centiseconds = centisecs; - wpt_tmp->position.altitude.altitude_meters = wpt_alt; + wpt_tmp->altitude = wpt_alt; route_add_wpt(track_head, wpt_tmp); } } @@ -441,12 +441,12 @@ mapsend_waypt_pr(const waypoint *waypointp) c = 1; fwrite(&c, 1, 1, mapsend_file_out); - falt = waypointp->position.altitude.altitude_meters; + falt = waypointp->altitude; my_fwrite8(&falt, mapsend_file_out); - flong = waypointp->position.longitude.degrees; + flong = waypointp->longitude; my_fwrite8(&flong, mapsend_file_out); - flat = -waypointp->position.latitude.degrees; + flat = -waypointp->latitude; my_fwrite8(&flat, mapsend_file_out); } @@ -503,10 +503,10 @@ mapsend_route_disp(const waypoint *waypointp) /* waypoint number */ my_fwrite4(&route_wp_count, mapsend_file_out); - dbl = waypointp->position.longitude.degrees; + dbl = waypointp->longitude; my_fwrite8(&dbl, mapsend_file_out); - dbl = -waypointp->position.latitude.degrees; + dbl = -waypointp->latitude; my_fwrite8(&dbl, mapsend_file_out); if (waypointp->icon_descr) { @@ -579,12 +579,14 @@ void mapsend_track_disp(const waypoint * wpt) static int last_time; /* - * Version 4.06 (at least) has a defect when it's set for .01km + * Firmware Ver 4.06 (at least) has a defect when it's set for .01km * tracking that will sometimes result in timestamps in the track * going BACKWARDS. When mapsend sees this, it (stupidly) advances * the date by one, ignoring the date on the TRK lines. This looks * for time travel and just uses the previous time - it's better to * be thought to be standing still than to be time-travelling! + * + * This is rumoured (but yet unconfirmed) to be fixed in f/w 5.12. */ t = wpt->creation_time; if (t < last_time) { @@ -592,15 +594,15 @@ void mapsend_track_disp(const waypoint * wpt) } /* x = longitude */ - dbl = wpt->position.longitude.degrees; + dbl = wpt->longitude; my_fwrite8(&dbl, mapsend_file_out); /* x = latitude */ - dbl = -wpt->position.latitude.degrees; + dbl = -wpt->latitude; my_fwrite8(&dbl, mapsend_file_out); /* altitude */ - i = wpt->position.altitude.altitude_meters; + i = wpt->altitude; my_fwrite4(&i, mapsend_file_out); /* time */ diff --git a/gpsbabel/mapsource.c b/gpsbabel/mapsource.c index 90011ea24..3106939bb 100644 --- a/gpsbabel/mapsource.c +++ b/gpsbabel/mapsource.c @@ -473,9 +473,9 @@ mps_waypoint_r(FILE *mps_file, int mps_ver, waypoint **wpt) thisWaypoint->shortname = xstrdup(wptname); thisWaypoint->description = xstrdup(wptdesc); - thisWaypoint->position.latitude.degrees = lat / 2147483648.0 * 180.0; - thisWaypoint->position.longitude.degrees = lon / 2147483648.0 * 180.0; - thisWaypoint->position.altitude.altitude_meters = mps_altitude; + thisWaypoint->latitude = lat / 2147483648.0 * 180.0; + thisWaypoint->longitude = lon / 2147483648.0 * 180.0; + thisWaypoint->altitude = mps_altitude; /* might need to change this to handle version dependent icon handling */ thisWaypoint->icon_descr = mps_find_desc_from_icon_number(icon, MAPSOURCE); @@ -494,8 +494,8 @@ mps_waypoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt) { unsigned char hdr[100]; int reclen; - int lat = wpt->position.latitude.degrees / 180.0 * 2147483648.0; - int lon = wpt->position.longitude.degrees / 180.0 * 2147483648.0; + int lat = wpt->latitude / 180.0 * 2147483648.0; + int lon = wpt->longitude / 180.0 * 2147483648.0; int icon; char *src; char *ident; @@ -504,7 +504,7 @@ mps_waypoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt) int display = 1; int colour = 0; /* (unknown colour) black is 1, white is 16 */ - double mps_altitude = wpt->position.altitude.altitude_meters; + double mps_altitude = wpt->altitude; double mps_proximity = unknown_alt; double mps_depth = unknown_alt; @@ -736,9 +736,9 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte) else { thisWaypoint = xcalloc(sizeof(*thisWaypoint), 1); thisWaypoint->shortname = xstrdup(wptname); - thisWaypoint->position.latitude.degrees = lat / 2147483648.0 * 180.0; - thisWaypoint->position.longitude.degrees = lon / 2147483648.0 * 180.0; - thisWaypoint->position.altitude.altitude_meters = mps_altitude; + thisWaypoint->latitude = lat / 2147483648.0 * 180.0; + thisWaypoint->longitude = lon / 2147483648.0 * 180.0; + thisWaypoint->altitude = mps_altitude; } route_add_wpt(rte_head, thisWaypoint); @@ -806,9 +806,9 @@ mps_route_r(FILE *mps_file, int mps_ver, route_head **rte) else { thisWaypoint = xcalloc(sizeof(*thisWaypoint), 1); thisWaypoint->shortname = xstrdup(wptname); - thisWaypoint->position.latitude.degrees = lat / 2147483648.0 * 180.0; - thisWaypoint->position.longitude.degrees = lon / 2147483648.0 * 180.0; - thisWaypoint->position.altitude.altitude_meters = mps_altitude; + thisWaypoint->latitude = lat / 2147483648.0 * 180.0; + thisWaypoint->longitude = lon / 2147483648.0 * 180.0; + thisWaypoint->altitude = mps_altitude; } route_add_wpt(rte_head, thisWaypoint); @@ -863,15 +863,15 @@ mps_routehdr_w(FILE *mps_file, int mps_ver, const route_head *rte) if (rte_datapoints == 0) { uniqueValue = testwpt->creation_time; } - if (testwpt->position.latitude.degrees > maxlat) maxlat = testwpt->position.latitude.degrees; - if (testwpt->position.latitude.degrees < minlat) minlat = testwpt->position.latitude.degrees; - if (testwpt->position.longitude.degrees > maxlon) maxlon = testwpt->position.longitude.degrees; - if (testwpt->position.longitude.degrees < minlon) minlon = testwpt->position.longitude.degrees; - if (testwpt->position.altitude.altitude_meters != unknown_alt) { - if ((testwpt->position.altitude.altitude_meters > maxalt) || - (maxalt == unknown_alt)) maxalt = testwpt->position.altitude.altitude_meters; - if ((testwpt->position.altitude.altitude_meters < minalt) || - (minalt == unknown_alt)) minalt = testwpt->position.altitude.altitude_meters; + if (testwpt->latitude > maxlat) maxlat = testwpt->latitude; + if (testwpt->latitude < minlat) minlat = testwpt->latitude; + if (testwpt->longitude > maxlon) maxlon = testwpt->longitude; + if (testwpt->longitude < minlon) minlon = testwpt->longitude; + if (testwpt->altitude != unknown_alt) { + if ((testwpt->altitude > maxalt) || + (maxalt == unknown_alt)) maxalt = testwpt->altitude; + if ((testwpt->altitude < minalt) || + (minalt == unknown_alt)) minalt = testwpt->altitude; } if(testwpt->description) src = testwpt->description; @@ -1017,15 +1017,15 @@ mps_routedatapoint_w(FILE *mps_file, int mps_ver, const waypoint *rtewpt) fwrite(&reclen, 4, 1, mps_file); /* output end point 1 */ - lat = prevRouteWpt->position.latitude.degrees / 180.0 * 2147483648.0; - lon = prevRouteWpt->position.longitude.degrees / 180.0 * 2147483648.0; + lat = prevRouteWpt->latitude / 180.0 * 2147483648.0; + lon = prevRouteWpt->longitude / 180.0 * 2147483648.0; le_write32(&lat, lat); le_write32(&lon, lon); fwrite(&lat, 4, 1, mps_file); fwrite(&lon, 4, 1, mps_file); - mps_altitude = prevRouteWpt->position.altitude.altitude_meters; + mps_altitude = prevRouteWpt->altitude; if (mps_altitude == unknown_alt) { fwrite(zbuf, 9, 1, mps_file); } @@ -1036,15 +1036,15 @@ mps_routedatapoint_w(FILE *mps_file, int mps_ver, const waypoint *rtewpt) } /* output end point 2 */ - lat = rtewpt->position.latitude.degrees / 180.0 * 2147483648.0; - lon = rtewpt->position.longitude.degrees / 180.0 * 2147483648.0; + lat = rtewpt->latitude / 180.0 * 2147483648.0; + lon = rtewpt->longitude / 180.0 * 2147483648.0; le_write32(&lat, lat); le_write32(&lon, lon); fwrite(&lat, 4, 1, mps_file); fwrite(&lon, 4, 1, mps_file); - mps_altitude = rtewpt->position.altitude.altitude_meters; + mps_altitude = rtewpt->altitude; if (mps_altitude == unknown_alt) { fwrite(zbuf, 9, 1, mps_file); } @@ -1054,31 +1054,31 @@ mps_routedatapoint_w(FILE *mps_file, int mps_ver, const waypoint *rtewpt) fwrite(&mps_altitude, 8 , 1, mps_file); } - if (rtewpt->position.latitude.degrees > prevRouteWpt->position.latitude.degrees) { - maxlat = rtewpt->position.latitude.degrees / 180.0 * 2147483648.0; - minlat = prevRouteWpt->position.latitude.degrees / 180.0 * 2147483648.0; + if (rtewpt->latitude > prevRouteWpt->latitude) { + maxlat = rtewpt->latitude / 180.0 * 2147483648.0; + minlat = prevRouteWpt->latitude / 180.0 * 2147483648.0; } else { - minlat = rtewpt->position.latitude.degrees / 180.0 * 2147483648.0; - maxlat = prevRouteWpt->position.latitude.degrees / 180.0 * 2147483648.0; + minlat = rtewpt->latitude / 180.0 * 2147483648.0; + maxlat = prevRouteWpt->latitude / 180.0 * 2147483648.0; } - if (rtewpt->position.longitude.degrees > prevRouteWpt->position.longitude.degrees) { - maxlon = rtewpt->position.longitude.degrees / 180.0 * 2147483648.0; - minlon = prevRouteWpt->position.longitude.degrees / 180.0 * 2147483648.0; + if (rtewpt->longitude > prevRouteWpt->longitude) { + maxlon = rtewpt->longitude / 180.0 * 2147483648.0; + minlon = prevRouteWpt->longitude / 180.0 * 2147483648.0; } else { - minlon = rtewpt->position.longitude.degrees / 180.0 * 2147483648.0; - maxlon = prevRouteWpt->position.longitude.degrees / 180.0 * 2147483648.0; + minlon = rtewpt->longitude / 180.0 * 2147483648.0; + maxlon = prevRouteWpt->longitude / 180.0 * 2147483648.0; } - if (rtewpt->position.altitude.altitude_meters != unknown_alt) maxalt = rtewpt->position.altitude.altitude_meters; - if (rtewpt->position.altitude.altitude_meters != unknown_alt) minalt = rtewpt->position.altitude.altitude_meters; - if (prevRouteWpt->position.altitude.altitude_meters != unknown_alt) { - if ((prevRouteWpt->position.altitude.altitude_meters > maxalt) || - (maxalt == unknown_alt)) maxalt = prevRouteWpt->position.altitude.altitude_meters; - if ((prevRouteWpt->position.altitude.altitude_meters < minalt) || - (minalt == unknown_alt)) minalt = prevRouteWpt->position.altitude.altitude_meters; + if (rtewpt->altitude != unknown_alt) maxalt = rtewpt->altitude; + if (rtewpt->altitude != unknown_alt) minalt = rtewpt->altitude; + if (prevRouteWpt->altitude != unknown_alt) { + if ((prevRouteWpt->altitude > maxalt) || + (maxalt == unknown_alt)) maxalt = prevRouteWpt->altitude; + if ((prevRouteWpt->altitude < minalt) || + (minalt == unknown_alt)) minalt = prevRouteWpt->altitude; } fwrite (zbuf, 1, 1, mps_file); @@ -1258,11 +1258,11 @@ mps_track_r(FILE *mps_file, int mps_ver, route_head **trk) } thisWaypoint = xcalloc(sizeof(*thisWaypoint), 1); - thisWaypoint->position.latitude.degrees = lat / 2147483648.0 * 180.0; - thisWaypoint->position.longitude.degrees = lon / 2147483648.0 * 180.0; + thisWaypoint->latitude = lat / 2147483648.0 * 180.0; + thisWaypoint->longitude = lon / 2147483648.0 * 180.0; thisWaypoint->creation_time = dateTime; thisWaypoint->centiseconds = 0; - thisWaypoint->position.altitude.altitude_meters = mps_altitude; + thisWaypoint->altitude = mps_altitude; route_add_wpt(track_head, thisWaypoint); } /* while (trk_count--) */ @@ -1355,12 +1355,12 @@ static void mps_trackdatapoint_w(FILE *mps_file, int mps_ver, const waypoint *wpt) { unsigned char hdr[10]; - int lat = wpt->position.latitude.degrees / 180.0 * 2147483648.0; - int lon = wpt->position.longitude.degrees / 180.0 * 2147483648.0; + int lat = wpt->latitude / 180.0 * 2147483648.0; + int lon = wpt->longitude / 180.0 * 2147483648.0; time_t t = wpt->creation_time; char zbuf[10]; - double mps_altitude = wpt->position.altitude.altitude_meters; + double mps_altitude = wpt->altitude; double mps_proximity = unknown_alt; double mps_depth = unknown_alt; diff --git a/gpsbabel/navicache.c b/gpsbabel/navicache.c index de6d2500c..127d9c885 100644 --- a/gpsbabel/navicache.c +++ b/gpsbabel/navicache.c @@ -112,15 +112,15 @@ nav_start(void *data, const char *el, const char **attr) } else if (0 == strcmp(ap[0], "latitude")) { sscanf(ap[1], "%lf", - &wpt_tmp->position.latitude.degrees); + &wpt_tmp->latitude); } else if (0 == strcmp(ap[0], "longitude")) { sscanf(ap[1], "%lf", - &wpt_tmp->position.longitude.degrees); + &wpt_tmp->longitude); } else if (0 == strcmp(ap[0], "longitude")) { sscanf(ap[1], "%lf", - &wpt_tmp->position.longitude.degrees); + &wpt_tmp->longitude); } else if (0 == strcmp(ap[0], "difficulty")) { float x; diff --git a/gpsbabel/pcx.c b/gpsbabel/pcx.c index e1a989484..112837a06 100644 --- a/gpsbabel/pcx.c +++ b/gpsbabel/pcx.c @@ -95,15 +95,15 @@ data_read(void) desc[sizeof(desc)-1] = '\0'; name[sizeof(name)-1] = '\0'; wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1); - wpt_tmp->position.altitude.altitude_meters = alt; + wpt_tmp->altitude = alt; wpt_tmp->shortname = xstrdup(name); wpt_tmp->description = xstrdup(desc); wpt_tmp->icon_descr = mps_find_desc_from_icon_number(symnum, PCX); if (latdir == 'S') lat = -lat; if (londir == 'W') lon = -lon; - wpt_tmp->position.longitude.degrees = ddmm2degrees(lon); - wpt_tmp->position.latitude.degrees = ddmm2degrees(lat); + wpt_tmp->longitude = ddmm2degrees(lon); + wpt_tmp->latitude = ddmm2degrees(lat); waypt_add(wpt_tmp); break; default: @@ -121,8 +121,8 @@ gpsutil_disp(const waypoint *wpt) char *tp = tbuf; time_t tm = wpt->creation_time; - lon = degrees2ddmm(wpt->position.longitude.degrees); - lat = degrees2ddmm(wpt->position.latitude.degrees); + lon = degrees2ddmm(wpt->longitude); + lat = degrees2ddmm(wpt->latitude); if (tm == 0) tm = time(NULL); diff --git a/gpsbabel/polygon.c b/gpsbabel/polygon.c index c4cd8e3fc..d68e92d06 100644 --- a/gpsbabel/polygon.c +++ b/gpsbabel/polygon.c @@ -238,8 +238,8 @@ polygon_process(void) last = 1; } polytest( lat1, lon1, lat2, lon2, - waypointp->position.latitude.degrees, - waypointp->position.longitude.degrees, + waypointp->latitude, + waypointp->longitude, &ed->state, first, last ); first = 0; last = 0; diff --git a/gpsbabel/position.c b/gpsbabel/position.c index 56eb7ec5d..c3ea570bd 100644 --- a/gpsbabel/position.c +++ b/gpsbabel/position.c @@ -92,10 +92,10 @@ position_comp(const void * a, const void * b) * point. */ - londiff = (x1->position.longitude.degrees - - x2->position.longitude.degrees) * 1000000.0; - latdiff = (x1->position.latitude.degrees - - x2->position.latitude.degrees) * 1000000.0; + londiff = (x1->longitude - + x2->longitude) * 1000000.0; + latdiff = (x1->latitude - + x2->latitude) * 1000000.0; max = fabs(londiff) >= fabs(latdiff) ? floor(londiff) : floor(latdiff); @@ -145,10 +145,10 @@ position_process(void) qsort(comp, wc, sizeof(waypoint *), position_comp); for (i = 0 ; i < (wc - 1) ; i++) { - dist = gc_distance(comp[i]->position.latitude.degrees, - comp[i]->position.longitude.degrees, - comp[i+1]->position.latitude.degrees, - comp[i+1]->position.longitude.degrees); + dist = gc_distance(comp[i]->latitude, + comp[i]->longitude, + comp[i+1]->latitude, + comp[i+1]->longitude); /* convert radians to integer feet */ dist = (int)((((dist * 180.0 * 60.0) / M_PI) * 1.1516) * 5280.0); @@ -197,10 +197,10 @@ radius_process(void) extra_data *ed; waypointp = (waypoint *)elem; - dist = gc_distance(waypointp->position.latitude.degrees, - waypointp->position.longitude.degrees, - home_pos->position.latitude.degrees, - home_pos->position.longitude.degrees); + dist = gc_distance(waypointp->latitude, + waypointp->longitude, + home_pos->latitude, + home_pos->longitude); /* convert radians to float point statute miles */ dist = (((dist * 180.0 * 60.0) / M_PI) * 1.1516); @@ -272,9 +272,9 @@ radius_init(const char *args) { home_pos = xcalloc(sizeof(*home_pos), 1); if (latopt) - home_pos->position.latitude.degrees = atof(latopt); + home_pos->latitude = atof(latopt); if (lonopt) - home_pos->position.longitude.degrees = atof(lonopt); + home_pos->longitude = atof(lonopt); } void diff --git a/gpsbabel/psitrex.c b/gpsbabel/psitrex.c index 2bb1a1482..e406c20f5 100755 --- a/gpsbabel/psitrex.c +++ b/gpsbabel/psitrex.c @@ -313,17 +313,17 @@ psit_waypoint_r(FILE *psit_file, waypoint **wpt) if (strlen(psit_current_token) > 0) { thisWaypoint = xcalloc(sizeof(*thisWaypoint), 1); - thisWaypoint->position.latitude.degrees = atof(psit_current_token); + thisWaypoint->latitude = atof(psit_current_token); psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), comma); - thisWaypoint->position.longitude.degrees = atof(psit_current_token); + thisWaypoint->longitude = atof(psit_current_token); psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), comma); if (psit_current_token[0] == '*') { - thisWaypoint->position.altitude.altitude_meters = unknown_alt; + thisWaypoint->altitude = unknown_alt; } else { - thisWaypoint->position.altitude.altitude_meters = atof(psit_current_token); + thisWaypoint->altitude = atof(psit_current_token); } /* the name */ @@ -359,14 +359,14 @@ psit_waypoint_w(FILE *psit_file, const waypoint *wpt) int colour = 0; /* (unknown colour) black is 1, white is 16 */ fprintf(psit_file, "%11.6f,%11.6f,", - wpt->position.latitude.degrees, - wpt->position.longitude.degrees); + wpt->latitude, + wpt->longitude); - if (wpt->position.altitude.altitude_meters == unknown_alt) + if (wpt->altitude == unknown_alt) fprintf(psit_file, "********,"); else fprintf(psit_file, "%8.2f,", - wpt->position.altitude.altitude_meters); + wpt->altitude); ident = global_opts.synthesize_shortnames ? mkshort(mkshort_handle, src) : @@ -439,17 +439,17 @@ psit_route_r(FILE *psit_file, route_head **rte) if (strlen(psit_current_token) > 0) { thisWaypoint = xcalloc(sizeof(*thisWaypoint), 1); - thisWaypoint->position.latitude.degrees = atof(psit_current_token); + thisWaypoint->latitude = atof(psit_current_token); psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), comma); - thisWaypoint->position.longitude.degrees = atof(psit_current_token); + thisWaypoint->longitude = atof(psit_current_token); psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), comma); if (psit_current_token[0] == '*') { - thisWaypoint->position.altitude.altitude_meters = unknown_alt; + thisWaypoint->altitude = unknown_alt; } else { - thisWaypoint->position.altitude.altitude_meters = atof(psit_current_token); + thisWaypoint->altitude = atof(psit_current_token); } /* the name */ @@ -569,17 +569,17 @@ psit_track_r(FILE *psit_file, route_head **trk) if (strlen(psit_current_token) > 0) { thisWaypoint = xcalloc(sizeof(*thisWaypoint), 1); - thisWaypoint->position.latitude.degrees = atof(psit_current_token); + thisWaypoint->latitude = atof(psit_current_token); psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), comma); - thisWaypoint->position.longitude.degrees = atof(psit_current_token); + thisWaypoint->longitude = atof(psit_current_token); psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), comma); if (psit_current_token[0] == '*') { - thisWaypoint->position.altitude.altitude_meters = unknown_alt; + thisWaypoint->altitude = unknown_alt; } else { - thisWaypoint->position.altitude.altitude_meters = atof(psit_current_token); + thisWaypoint->altitude = atof(psit_current_token); } /* date portion of the date time DD/MM/YY */ @@ -696,19 +696,19 @@ psit_trackdatapoint_w(FILE *psit_file, const waypoint *wpt) time_t t = wpt->creation_time; struct tm *tmTime = gmtime(&t); - double psit_altitude = wpt->position.altitude.altitude_meters; + double psit_altitude = wpt->altitude; double psit_proximity = unknown_alt; double psit_depth = unknown_alt; fprintf(psit_file, "%11.6f,%11.6f,", - wpt->position.latitude.degrees, - wpt->position.longitude.degrees); + wpt->latitude, + wpt->longitude); - if (wpt->position.altitude.altitude_meters == unknown_alt) + if (wpt->altitude == unknown_alt) fprintf(psit_file, "********, "); else fprintf(psit_file, "%8.2f, ", - wpt->position.altitude.altitude_meters); + wpt->altitude); /* Following date time format is fixed and reveals the origin of PsiTrex (i.e. the UK) */ fprintf(psit_file, "%02d/%02d/%02d %02d:%02d:%02d,", diff --git a/gpsbabel/psp.c b/gpsbabel/psp.c index b07657498..20737ef34 100644 --- a/gpsbabel/psp.c +++ b/gpsbabel/psp.c @@ -298,7 +298,7 @@ psp_read(void) while (pincount--) { wpt_tmp = xcalloc(sizeof(*wpt_tmp),1); - wpt_tmp->position.altitude.altitude_meters = unknown_alt; + wpt_tmp->altitude = unknown_alt; /* offset 0x20 - 0x21 pin index */ psp_fread(&pindex, 1, 2, psp_file_in); @@ -326,8 +326,8 @@ psp_read(void) decode_psp_coordinates(&lat, &lon, gridbyte); - wpt_tmp->position.latitude.degrees = lat; - wpt_tmp->position.longitude.degrees = lon; + wpt_tmp->latitude = lat; + wpt_tmp->longitude = lon; /* 1 byte - pin display properties */ psp_fread(&buff[0], 1, 1, psp_file_in); @@ -430,8 +430,8 @@ psp_waypt_pr(const waypoint *wpt) } /* convert lat/long back to radians */ - lat = (wpt->position.latitude.degrees * M_PI) / 180.0; - lon = (wpt->position.longitude.degrees * M_PI) / 180.0; + lat = (wpt->latitude * M_PI) / 180.0; + lon = (wpt->longitude * M_PI) / 180.0; pindex++; le_write16(tbuf, pindex); @@ -444,8 +444,8 @@ psp_waypt_pr(const waypoint *wpt) /* set the grid byte */ - c = grid_byte(wpt->position.latitude.degrees, - wpt->position.longitude.degrees); + c = grid_byte(wpt->latitude, + wpt->longitude); /* since the grid byte matches with what pocketstreets does to */ /* input files, our output appears identical to a pin file that */ diff --git a/gpsbabel/quovadis.c b/gpsbabel/quovadis.c index 3cc67243f..c0fe54353 100644 --- a/gpsbabel/quovadis.c +++ b/gpsbabel/quovadis.c @@ -139,9 +139,9 @@ data_read(void) rec = (struct record *) &(pdb_rec->data[i * sizeof(struct record)]); - wpt_tmp->position.longitude.degrees = + wpt_tmp->longitude = (be_read32(&rec->longitude) / 1000000.0) - 180.0; - wpt_tmp->position.latitude.degrees = + wpt_tmp->latitude = 90.0 - (be_read32(&rec->latitude) / 1000000.0); wpt_tmp->shortname = xstrdup(rec->name); @@ -179,9 +179,9 @@ quovadis_writewpt(waypoint *wpt) rec = xcalloc(sizeof(*rec),1); - be_write32(&rec->longitude, (wpt->position.longitude.degrees + + be_write32(&rec->longitude, (wpt->longitude + 180.0) * 1000000.0); - be_write32(&rec->latitude, (90.0 - wpt->position.latitude.degrees) * 1000000.0); + be_write32(&rec->latitude, (90.0 - wpt->latitude) * 1000000.0); if ( wpt->shortname ) { strncpy(rec->name, wpt->shortname, 32 ); rec->name[31] = '\0'; diff --git a/gpsbabel/saroute.c b/gpsbabel/saroute.c index 40110825e..7d795e652 100644 --- a/gpsbabel/saroute.c +++ b/gpsbabel/saroute.c @@ -148,8 +148,8 @@ my_read(void) le_read32(&latlon->lon)) / (double)(0x800000); wpt_tmp = xcalloc(sizeof (*wpt_tmp), 1); - wpt_tmp->position.latitude.degrees = lat; - wpt_tmp->position.longitude.degrees = -lon; + wpt_tmp->latitude = lat; + wpt_tmp->longitude = -lon; route_add_wpt(track_head, wpt_tmp); } else { Skip(infile, recsize); @@ -208,8 +208,8 @@ my_read(void) lon = (0x80000000UL - le_read32(&latlon->lon)) / (double)(0x800000); - wpt_tmp->position.latitude.degrees = lat; - wpt_tmp->position.longitude.degrees = -lon; + wpt_tmp->latitude = lat; + wpt_tmp->longitude = -lon; route_add_wpt(track_head, wpt_tmp); latlon++; diff --git a/gpsbabel/tiger.c b/gpsbabel/tiger.c index ab786d6d8..8e37e4188 100644 --- a/gpsbabel/tiger.c +++ b/gpsbabel/tiger.c @@ -142,8 +142,8 @@ data_read(void) &lon, &lat, icon, desc)) { wpt_tmp = xcalloc(sizeof (*wpt_tmp), 1); - wpt_tmp->position.longitude.degrees = lon; - wpt_tmp->position.latitude.degrees = lat; + wpt_tmp->longitude = lon; + wpt_tmp->latitude = lat; wpt_tmp->description = xstrdup(desc); wpt_tmp->shortname = mkshort(mkshort_handle, desc); @@ -156,8 +156,8 @@ static void tiger_disp(const waypoint *wpt) { const char *pin; - double lat = wpt->position.latitude.degrees; - double lon = wpt->position.longitude.degrees; + double lat = wpt->latitude; + double lon = wpt->longitude; if (iconismarker) pin = wpt->icon_descr ? wpt->icon_descr : ""; diff --git a/gpsbabel/tmpro.c b/gpsbabel/tmpro.c index 1343a72d7..ba5d09fb3 100644 --- a/gpsbabel/tmpro.c +++ b/gpsbabel/tmpro.c @@ -118,10 +118,10 @@ data_read(void) wpt_tmp->description = holder; break; case 3: - wpt_tmp->position.latitude.degrees = atof(s); + wpt_tmp->latitude = atof(s); break; case 4: - wpt_tmp->position.longitude.degrees = atof(s); + wpt_tmp->longitude = atof(s); break; case 5: /* ignore: NZMapGrid Easting */ @@ -130,7 +130,7 @@ data_read(void) /* ignore: NZMapGrid Northing */ break; case 7: - wpt_tmp->position.altitude.altitude_meters = atof(s); + wpt_tmp->altitude = atof(s); break; case 8: /* ignore: color */ @@ -215,9 +215,9 @@ tmpro_waypt_pr(const waypoint * wpt) fprintf(file_out, "new\t%.6s\t%.80s\t%08.6f\t%08.6f\t\t\t%.2f\t%d\t%d\t%.128s\n", shortname, description, - wpt->position.latitude.degrees, - wpt->position.longitude.degrees, - wpt->position.altitude.altitude_meters, + wpt->latitude, + wpt->longitude, + wpt->altitude, colour, icon, wpt->url diff --git a/gpsbabel/tpg.c b/gpsbabel/tpg.c index 44bd48ea9..165d2809e 100644 --- a/gpsbabel/tpg.c +++ b/gpsbabel/tpg.c @@ -221,12 +221,12 @@ tpg_read(void) lat, lon, 0.0, - &wpt_tmp->position.latitude.degrees, - &wpt_tmp->position.longitude.degrees, + &wpt_tmp->latitude, + &wpt_tmp->longitude, &amt, 78); - wpt_tmp->position.altitude.altitude_meters = elev; + wpt_tmp->altitude = elev; /* 4 bytes? */ @@ -299,8 +299,8 @@ tpg_waypt_pr(const waypoint *wpt) /* convert lat/long to NAD27/CONUS datum */ GPS_Math_WGS84_To_Known_Datum_M( - wpt->position.latitude.degrees, - wpt->position.longitude.degrees, + wpt->latitude, + wpt->longitude, 0.0, &lat, &lon, @@ -312,7 +312,7 @@ tpg_waypt_pr(const waypoint *wpt) lon *= -1.0; /* convert meters back to feets */ - elev = (short int) (wpt->position.altitude.altitude_meters * 3.2808); + elev = (short int) (wpt->altitude * 3.2808); /* 1 bytes stringsize for shortname */ c = strlen(shortname); diff --git a/gpsbabel/util.c b/gpsbabel/util.c index de96b5959..c0e7684eb 100644 --- a/gpsbabel/util.c +++ b/gpsbabel/util.c @@ -270,36 +270,36 @@ case_ignore_strcmp(const char *s1, const char *s2) } -coord +double mkposn(const char *string) { - coord coord = {0}; - sscanf(string, "%lf", &coord.degrees); + double coord; + sscanf(string, "%lf", &coord); return coord; } void -printposn(const coord *c, int is_lat) +printposn(const float c, int is_lat) { char d; if (is_lat) { - if (c->degrees < 0) d = 'S'; else d = 'N'; + if (c < 0) d = 'S'; else d = 'N'; } else { - if (c->degrees < 0) d = 'W'; else d = 'E'; + if (c < 0) d = 'W'; else d = 'E'; } - printf("%f%c ", fabs(c->degrees), d); + printf("%f%c ", fabs(c), d); } void -fprintdms(FILE *file, const coord *c, int is_lat) +fprintdms(FILE *file, const double c, int is_lat) { char d; if (is_lat) { - if (c->degrees < 0) d = 'S'; else d = 'N'; + if (c < 0) d = 'S'; else d = 'N'; } else { - if (c->degrees < 0) d = 'W'; else d = 'E'; + if (c < 0) d = 'W'; else d = 'E'; } - fprintf(file, "%c%f\t", d, fabs(c->degrees)); + fprintf(file, "%c%f\t", d, fabs(c)); } void diff --git a/gpsbabel/waypt.c b/gpsbabel/waypt.c index cb6e26dd5..b29ab9b3c 100644 --- a/gpsbabel/waypt.c +++ b/gpsbabel/waypt.c @@ -105,15 +105,15 @@ waypt_disp(const waypoint *wpt) if (wpt->creation_time) { printf("%s ", ctime(&wpt->creation_time)); } - printposn(&wpt->position.latitude,1); - printposn(&wpt->position.longitude,0); + printposn(wpt->latitude,1); + printposn(wpt->longitude,0); printf("%s/%s", global_opts.synthesize_shortnames ? mkshort(mkshort_handle, wpt->description) : wpt->shortname, wpt->description); - if (wpt->position.altitude.altitude_meters != unknown_alt) - printf(" %f", wpt->position.altitude.altitude_meters); + if (wpt->altitude != unknown_alt) + printf(" %f", wpt->altitude); printf("\n"); } -- 2.30.2